//
//  UIStandardButton.m
//  vhStressECG
//
//  Created by jia yu on 2021/12/13.
//

#import "UIStandardButton.h"
#import <vhECGTools/vhECGTools.h>
@interface UIStandardButton(){
    float scale;
}
@end

@implementation UIStandardButton
-(id)initWithFrame:(CGRect)frame scale:(float)_scale{
    self = [super initWithFrame:frame];
    if (self){
        scale = _scale;
        UIImage *image = [vhECGTools createImageWithColor:[vhECGTools colorFromHEXString:@"f6fcfc"] size:frame.size];
        [self setBackgroundImage:image forState:UIControlStateNormal];
        image = [vhECGTools createImageWithColor:[vhECGTools colorFromHEXString:@"e6f7f7" withAlpha:0.4f] size:frame.size];
        [self setBackgroundImage:image forState:UIControlStateDisabled];
        image = [vhECGTools createImageWithColor:[vhECGTools colorFromHEXString:@"e6f7f7"] size:frame.size];
        [self setBackgroundImage:image forState:UIControlStateHighlighted];
        
        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 10.f * scale;
        self.layer.borderColor = [vhECGTools colorFromHEXString:@"d9eded"].CGColor;
        self.layer.borderWidth = 1.f * scale;
        
        self.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:34.f * scale];
        [self setTitleColor:[vhECGTools colorFromHEXString:@"294559"] forState:UIControlStateNormal];
        [self setTitleColor:[vhECGTools colorFromHEXString:@"294559" withAlpha:0.4f] forState:UIControlStateDisabled];
        [self setTitleColor:[vhECGTools colorFromHEXString:@"52b6b8"] forState:UIControlStateHighlighted];
    }
    return self;
}

-(id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self){
        self.backgroundColor = [UIColor colorWithRed:0.98 green:0.99 blue:0.99 alpha:1.f];
        [self setTitleColor:[UIColor colorWithRed:0.1 green:0.21 blue:0.29 alpha:1.f] forState:UIControlStateNormal];
        [self setTitleColor:[UIColor colorWithRed:0.48 green:0.56 blue:0.61 alpha:1.f] forState:UIControlStateDisabled];
        
        self.layer.masksToBounds = YES;
        self.layer.maskedCorners = frame.size.height/6.f;
        self.layer.borderColor = [UIColor colorWithRed:0.89 green:0.95 blue:0.95 alpha:1.f].CGColor;
        self.layer.borderWidth = frame.size.height/60.f;
        
        self.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:self.frame.size.height/2.f];
        [self setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
    }
    return self;
}
@end
